package SellCar.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import SellCar.pojo.Buy;
import SellCar.service.BuyBiz;
import SellCar.service.impl.BuyBizImpl;

public class BuyServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			this.doPost(request, response);

	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=utf-8");
		PrintWriter out = response.getWriter();
		HttpSession session = request.getSession();
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		
		BuyBiz biz = new BuyBizImpl();
		
		String opr = request.getParameter("opr");
		if("buy".equals(opr)){
			List<Buy> buyList = biz.getBuyList();
			session.setAttribute("buyList", buyList);
			response.sendRedirect("showBuy.jsp");
		}
		
		
	}

}
